package com.whnk.model.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.whnk.common.log.annotation.Log;
import com.whnk.common.log.enums.BusinessType;
import com.whnk.common.security.annotation.PreAuthorize;
import com.whnk.model.domain.SrcTIndexInfo;
import com.whnk.model.service.ISrcTIndexInfoService;
import com.whnk.common.core.web.controller.BaseController;
import com.whnk.common.core.web.domain.AjaxResult;
import com.whnk.common.core.utils.poi.ExcelUtil;
import com.whnk.common.core.web.page.TableDataInfo;

/**
 * 指标数据源Controller
 * 
 * @author whnk
 * @date 2021-11-25
 */
@RestController
@RequestMapping("/srcTIndexInfo")
public class SrcTIndexInfoController extends BaseController
{
    @Autowired
    private ISrcTIndexInfoService srcTIndexInfoService;

    /**
     * 查询指标数据源列表
     */
   // @PreAuthorize(hasPermi = "model:info:list")
    @GetMapping("/list")
    public TableDataInfo list(SrcTIndexInfo srcTIndexInfo)
    {
        startPage();
        List<SrcTIndexInfo> list = srcTIndexInfoService.selectSrcTIndexInfoList(srcTIndexInfo);
        return getDataTable(list);
    }


    /**
     * 获取指标数据源详细信息
     */
  //  @PreAuthorize(hasPermi = "model:info:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(srcTIndexInfoService.selectSrcTIndexInfoById(id));
    }

    /**
     * 新增指标数据源
     */
   // @PreAuthorize(hasPermi = "model:info:add")
    @Log(title = "指标数据源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SrcTIndexInfo srcTIndexInfo)
    {
        return toAjax(srcTIndexInfoService.insertSrcTIndexInfo(srcTIndexInfo));
    }

    /**
     * 修改指标数据源
     */
   // @PreAuthorize(hasPermi = "model:info:edit")
    @Log(title = "指标数据源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SrcTIndexInfo srcTIndexInfo)
    {
        return toAjax(srcTIndexInfoService.updateSrcTIndexInfo(srcTIndexInfo));
    }

    /**
     * 删除指标数据源
     */
    //@PreAuthorize(hasPermi = "model:info:remove")
    @Log(title = "指标数据源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(srcTIndexInfoService.deleteSrcTIndexInfoByIds(ids));
    }
}
